<?php use_helper('I18N') ?>

<script type="text/javascript">
    $(function() {
        $(".editLink").button({
                    icons: {
                        primary: "ui-icon-circle-check"
                    }
                })
        $("#btnCreate").button({
                    icons: {
                        primary: "ui-icon-circle-plus"
                    }
                })
    });
</script>
<div style="padding: 10px; top: 10px; width: 98%">
    <div class="portlet" id="sf_admin_container">
        <div class="portlet-header">Product</div>
        <div class="portlet-content" id="sf_admin_content" style="width: 98%">
            <table class="sf_admin_list" width="100%">
                <thead>
                <tr>
                    <th></th>
                    <th>Categories</th>
                    <th>Product code</th>
                    <th>Product name</th>
                    <th>Product desc</th>
                    <th>Product short desc</th>
                    <th>Product name cn</th>
                    <th>Product desc cn</th>
                    <th>Product short desc cn</th>
                    <th>Product photo</th>
                    <th>Price</th>
                    <th>Price<br>(Before Discount)</th>
                    <th>Total unit</th>
                    <th>Rate</th>
                    <th>Special item</th>
                    <th>Status code</th>
                </tr>
                </thead>
                <tbody>
                <?php
                $className = "sf_admin_row_1";
                foreach ($cms_products as $cms_product):
                    if ($className == "sf_admin_row_0") {
                        $className = "sf_admin_row_1";
                    } else {
                        $className = "sf_admin_row_0";
                    }
                    $cmsCategory = CmsCategoriesPeer::retrieveByPK($cms_product->getCategoriesId());
                ?>
                <script type="text/javascript">
                    $(function(){
                        $("a[rel=image_group<?php echo $cms_product->getProductId() ?>]").fancybox({
                            'transitionIn' : 'elastic',
                            'transitionOut' : 'none'
                        });
                    });
                </script>
                <tr>
                    <td><?php echo link_to("Edit", 'product/productEdit?product_id=' . $cms_product->getProductId(), array ('class' => 'editLink')) ?></td>
                    <td><?php echo $cmsCategory->getCategoriesName() ?></td>
                    <td><?php echo $cms_product->getProductCode() ?></td>
                    <td><?php echo $cms_product->getProductName() ?></td>
                    <td><?php echo $cms_product->getProductDesc() ?></td>
                    <td><?php echo $cms_product->getProductShortDesc() ?></td>
                    <td><?php echo $cms_product->getProductNameCn() ?></td>
                    <td><?php echo $cms_product->getProductDescCn() ?></td>
                    <td><?php echo $cms_product->getProductShortDescCn() ?></td>
                    <td>
                        <?php //echo $cms_product->getProductPhoto() ?>
                        <?php echo "<a rel='image_group".$cms_product->getProductId()."' href='/uploads/products/".$cms_product->getProductPhoto()."'>"; ?>
                            <img onerror="this.src='/images/common/not_available.gif';"
                                                         src="<?php echo '/'.sfConfig::get('sf_upload_dir_name').'/products/thumbnails/'.$cms_product->getProductPhoto(); ?> "
                                                         height="100">
                            </a>
                    </td>
                    <td><?php echo $cms_product->getPrice() ?></td>
                    <td><?php echo $cms_product->getPrice2() ?></td>
                    <td><?php echo $cms_product->getTotalUnit() ?></td>
                    <td><?php echo $cms_product->getRate() ?></td>
                    <td><?php
                        if ($cms_product->getSpecialItem() == 1)
                            echo "YES";
                        else
                            echo "NO";
                        ?></td>
                    <td><?php echo $cms_product->getStatusCode() ?></td>
                </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>

            <br>

            <div style="text-align: right">
                <?php echo link_to('create', 'settings/categoriesCreate', array("id" => "btnCreate")) ?>
            </div>

        </div>
    </div>
</div>
